package com.zyy.springbootdata.controller;

import com.github.pagehelper.PageInfo;
import com.zyy.springbootdata.pojo.Article;
import com.zyy.springbootdata.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author zyy
 * @date 2020/12/20 下午7:58
 * @description
 */
@Controller
public class IndexController {
    @Autowired
    private ArticleService articleService;

    @RequestMapping("/index")
    public String index(Model model, @RequestParam(value="pageNum",defaultValue="1")int pageNum, @RequestParam(value="pageSize",defaultValue="2")int pageSize){
        PageInfo<Article> pageInfo = articleService.findList(pageNum, pageSize);
        model.addAttribute("pageInfo",pageInfo);
        return "index";
    }
}
